import random

seed,n = input().split()
seed = int(seed)
n = int(n)
random.seed(seed)
martix = []
for i in range(n):
    line = [random.randint(0,100) for i in range(n)]
    martix.append(line)
tran_martix = []
for i in range(n):
    tran_martix.append([col[i] for col in martix])
print(martix)
print(tran_martix)